#coding:utf-8

from flask import Flask
from flask import request
from flask import render_template
import time 

app = Flask(__name__)

@app.route('/', methods=['GET'])
def home():
	return render_template('welcome.html', anwser="  ")

@app.route('/sign', methods=['GET'])
def signin():
	return render_template('sign_form.html')
	
@app.route('/', methods=['POST'])
def deal_home():
	# return render_template('welcome.html', anwser=request.form['anwser'])
	if request.form['anwser'] == '144':
		# return render_template('welcome.html', anwser=request.form['anwser'])
		# time.sleep(2)
		return render_template('sign_form.html')
	else:	
		return render_template('welcome.html', anwser="回答错误，请重新输入……")

@app.route('/sign', methods=['POST'])
def deal_sign():
	if request.form['username'] == 'admin' and request.form['password'] == 'password':
		return '<h3>Hello Admin!</h3>'
	else:	
		return '<h3>你无权访问404</h3>'

if __name__ == '__main__':
	app.run(host='localhost', port=5556)
	